<template>
    <wsPage title="推荐列表">
        <div slot="page_operate">
			<Button @click="refresh"><Icon type="refresh"></Icon><span>刷新</span></Button>
		</div>
        <wsSmPanel :page="table.page" @page-change="hasChangeType" @simple-query="hasChangeType">
            <!-- 筛选查询 -->
            <div slot="query_form">
				<Form :model="queryForm" :label-width="100">
					<FormItem>
						<RadioGroup v-model="queryForm.type" type="button" @on-change="hasChangeType" size="large">
					        <Radio :label="item.type" v-for="(item,index) in navTab.navTabList" :key="index">{{item.name}}</Radio>
					    </RadioGroup>
			        </FormItem>
				</Form>
			</div>
            <!-- 数据列表 -->
            <div slot="list_operate" v-if="chooseBanner">
                <!-- 筛选banner -->
                <Select class="ws-form-select" v-model="queryForm.selfStatus" @on-change="chooseSlelfStatus">
                    <Option :value="item.status"  v-for="(item,index) in onSelf.selfStatus" v-bind:key="index">{{item.name}}</Option>
                </Select>
				<Select class="ws-form-select" v-model="queryForm.languageCode" @on-change="chooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
				<Button @click="gotoAddReco">添加推荐</Button>
			</div>
            <div slot="list_operate" v-if="chooseActivities">
                <!-- 筛选活动 -->
                <!-- <Select class="ws-form-select" v-model="queryForm.languageCode" @on-change="chooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select> -->
            </div>
            <div slot="list_operate" v-if="chooseTopics">
                <!-- 筛选主题 -->
                <Select class="ws-form-select" v-model="addRecoTopic.selfStatus" @on-change="topicChooseSlelfStatus">
                    <Option :value="item.status"  v-for="(item,index) in onSelf.selfStatus" v-bind:key="index">{{item.name}}</Option>
                </Select>
				<Select class="ws-form-select" v-model="addRecoTopic.languageCode" @on-change="topicChooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
				<Button @click="isShow=true">添加推荐</Button>
            </div>
            <div slot="list_operate" v-if="chooseShops">
                <!-- 筛选店铺 -->
                <Select class="ws-form-select" v-model="chooseShopDataList.selfStatus" @on-change="shopChooseSlelfStatus">
                    <Option :value="item.status"  v-for="(item,index) in shopOnSelf.selfStatus" v-bind:key="index">{{item.name}}</Option>
                </Select>
				<Select class="ws-form-select" v-model="chooseShopDataList.languageCode" @on-change="shopChooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
				<Button @click="shopRecoShow=true">添加推荐</Button>
            </div>
            <div slot="list_operate" v-if="chooseGoods">
                <!-- 筛选商品 -->
                <Select class="ws-form-select" v-model="addRecoGoods.selfStatus" @on-change="goodsChooseSlelfStatus">
                    <Option :value="item.status"  v-for="(item,index) in goodsOnSelf.selfStatus" v-bind:key="index">{{item.name}}</Option>
                </Select>
				<Select class="ws-form-select" v-model="addRecoGoods.languageCode" @on-change="goodsChooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
                <Button v-if="addRecoGoods.selfStatus==1" @click="selectSomeObtain">批量下架</Button>
                <Button v-if="addRecoGoods.selfStatus==0" @click="selectSomeOnSelf">批量上架</Button>
				<Button @click="showRecoGoods">添加推荐</Button>
            </div>   
            <div slot="list_operate" v-if="chooseSaleGoods">
                <!-- 筛选折扣商品 -->
                <Select class="ws-form-select" v-model="addRecoSaleGoods.selfStatus" @on-change="saleGoodsChooseSlelfStatus">
                    <Option :value="item.status"  v-for="(item,index) in goodsOnSelf.selfStatus" v-bind:key="index">{{item.name}}</Option>
                </Select>
				<Select class="ws-form-select" v-model="addRecoSaleGoods.languageCode" @on-change="saleGoodsChooseLanguageCode">
					<Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
				</Select>
                <!-- <Button v-if="addRecoSaleGoods.selfStatus==1" @click="saleSelectSomeObtain">批量下架</Button> -->
                <!-- <Button v-if="addRecoSaleGoods.selfStatus==0" @click="saleSelectSomeOnSelf">批量上架</Button> -->
				<Button @click="pop">添加推荐</Button>
            </div>  
            <!-- content -->
            <div slot="list_data">
                <!-- banner数据列表 -->
                <ws-table v-show="chooseBanner" :data="table.data" style="width: 100%" >
                    <ws-table-column  label="区域" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.position}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="类型" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.typeName}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column  label="主图" min-width="180" align="center">
                        <template slot-scope="scope">
                            <img :src="scope.row.imgUrl" alt="" style="width: 135px;height: 100px;"/>
                        </template>   
                    </ws-table-column>
                    <ws-table-column  label="名称" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.name}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column  label="顺序" min-width="180" align="center" v-if="queryForm.selfStatus==2">
                        <template slot-scope="scope">
                            <span>{{scope.row.orderNum}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="语言" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.language}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="操作" min-width="180" align="center">
                        <template slot-scope="scope">
                            <Button size="small" type="text" @click="shelf(scope.row)" v-if="queryForm.selfStatus==1||queryForm.selfStatus==3">上架</Button>
                            <Button size="small" type="text" @click="Obtained(scope.row)" v-if="queryForm.selfStatus==2">下架</Button>
                            <Button size="small" type="text" @click="moveUp(scope.row)" v-if="queryForm.selfStatus==2">上移</Button>
                            <Button size="small" type="text" @click="moveDown(scope.row)" v-if="queryForm.selfStatus==2">下移</Button>
                            <Button size="small" type="text" @click="goTop(scope.row)" v-if="queryForm.selfStatus==2">置顶</Button>
                            <Button size="small" type="text" @click="deleteBanner(scope.row)" v-if="queryForm.selfStatus==1||queryForm.selfStatus==3">删除</Button>
                        </template>
                    </ws-table-column>
                </ws-table>
                <!-- 活动数据列表 -->
                <ws-table v-show="chooseActivities" style="width: 100%" >
                    <ws-table-column prop="position" label="区域" min-width="180" align="center"></ws-table-column>
					<ws-table-column  label="名称" min-width="180" align="center">
                        <template slot-scope="scope">
                            <img :src="scope.row.imgUrl" alt="" style="width: 100px;height: 100px;"/>
                        </template>   
                    </ws-table-column>                   
					<ws-table-column prop="orderNum" label="顺序" min-width="180" align="center"></ws-table-column>
                    <ws-table-column prop="name" label="状态" min-width="180" align="center"></ws-table-column>
                    <ws-table-column prop="language" label="语言" min-width="180" align="center"></ws-table-column>
					<ws-table-column label="操作" min-width="180" align="center">
                        <template slot-scope="scope">
                            <!-- <Button size="small" type="text" @click="shelf(scope.row)">上架</Button>
                            <Button size="small" type="text" @click="Obtained(scope.row)">下架</Button>
                            <Button size="small" type="text" @click="moveUp(scope.row)">上移</Button>
                            <Button size="small" type="text" @click="moveDown(scope.row)">下移</Button>
                            <Button size="small" type="text" @click="goTop(scope.row)">置顶</Button>
                            <Button size="small" type="text" @click="deleteBanner(scope.row)">删除</Button> -->
                        </template>
                    </ws-table-column>
                </ws-table> 
                <!-- 主题数据列表 -->
                <ws-table v-show="chooseTopics" :data="addRecoTopic.recoTopicList"  style="width: 100%" >
                    <ws-table-column  label="区域" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.position}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="分类" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.topicCategoryName}}</span>
                        </template>
                    </ws-table-column>                   
					<ws-table-column label="名称" min-width="280" align="center">                        
                        <template slot-scope="scope">
                            <Row v-for="(item,index) in (scope.row.topics)" :key="index" style="width:250px;height:100px;display:flex;">
                                <img :src="item.coverImgUrl" alt="" style="width:160px;height:90px;">
                                <span style="margin-left:15px;width:200px;height:90px;">{{item.name}}</span>
                            </Row>                         
                        </template> 

                    </ws-table-column>
                    <ws-table-column label="顺序" min-width="180" align="center" v-if="addRecoTopic.selfStatus==2">
                        <template slot-scope="scope">
                            <span>{{scope.row.orderNum}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="状态" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.statusStr}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="语言" min-width="180" align="center">
                         <template slot-scope="scope">
                            <span>{{scope.row.language}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="操作" min-width="180" align="center">
                        <template slot-scope="scope">
                            <Button size="small" type="text" @click="topicShelf(scope.row)" v-if="addRecoTopic.selfStatus==1||addRecoTopic.selfStatus==3">上架</Button>
                            <Button size="small" type="text" @click="topicObtained(scope.row)" v-if="addRecoTopic.selfStatus==2">下架</Button>
                            <Button size="small" type="text" @click="topicMoveUp(scope.row)" v-if="addRecoTopic.selfStatus==2">上移</Button>
                            <Button size="small" type="text" @click="topicMoveDown(scope.row)" v-if="addRecoTopic.selfStatus==2">下移</Button>
                            <Button size="small" type="text" @click="topicGoTop(scope.row)" v-if="addRecoTopic.selfStatus==2">置顶</Button>
                            <Button size="small" type="text" @click="topicDeleteBanner(scope.row)" v-if="addRecoTopic.selfStatus==1||addRecoTopic.selfStatus==3">删除</Button>
                        </template>
                    </ws-table-column>
                </ws-table>
                <!-- 推荐店铺数据列表 -->
                <ws-table v-show="chooseShops" :data="chooseShopDataList.shopRecoList" style="width: 100%" >
                    
                    <ws-table-column label="区域" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.position}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="封面" min-width="180" align="center">
                         <template slot-scope="scope">
                            <img :src="scope.row.bgImgUrl" alt="" style="width: 160px;height: 160px;"/>
                        </template> 
                    </ws-table-column>                   
					<ws-table-column label="名称" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.company}}</span>
                        </template>
                    </ws-table-column>
                     <!-- <ws-table-column label="一句话简介" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.wDesc}}</span>
                        </template>
                     </ws-table-column> -->
                    <ws-table-column label="状态" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.statusStr}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column label="语言" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.language}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="操作" min-width="180" align="center">
                      <template slot-scope="scope">
                            <Button size="small" type="text" @click="shopShelf(scope.row)" v-if="chooseShopDataList.selfStatus==1||chooseShopDataList.selfStatus==3">上架</Button>
                            <Button size="small" type="text" @click="shopObtained(scope.row)" v-if="chooseShopDataList.selfStatus==2">下架</Button>
                            <Button size="small" type="text" @click="moveStoreUp(scope.row)" v-if="queryForm.selfStatus==2">上移</Button>
                            <Button size="small" type="text" @click="moveStoreDown(scope.row)" v-if="queryForm.selfStatus==2">下移</Button>
                            <Button size="small" type="text" @click="goStoreTop(scope.row)" v-if="queryForm.selfStatus==2">置顶</Button>
                            <Button size="small" type="text" @click="shopDeleteBanner(scope.row)" v-if="chooseShopDataList.selfStatus==1||chooseShopDataList.selfStatus==3">删除</Button>
                        </template>
                    </ws-table-column> 
                </ws-table>
                <!-- 推荐商品数据列表 -->
                <ws-table v-show="chooseGoods" :data="addRecoGoods.recoGoodsList"  ref="table"   @selection-change="chooseGoodsSectonChange"   style="width: 100%" >
                    <ws-table-column align="center" type="selection" width="80" fixed="left"  ></ws-table-column>
                    <ws-table-column label="区域" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.position}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column label="商品信息" min-width="250" align="center">
                        <template slot-scope="scope">
                            <div style="display:flex;align-items:top;">
                                <img :src="scope.row.imgUrl" alt="" style="width:60px;height:60px;">
                                <span >{{scope.row.productName}}</span>
                                <!-- <span>{{scope.row.price}}</span> -->
                            </div>                            
                        </template>
                    </ws-table-column>
                    <ws-table-column label="推荐时间" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.recommendDate}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="语言" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.language}}</span>
                        </template>
                    </ws-table-column>
					<ws-table-column label="操作" min-width="180" align="center">
                        <template slot-scope="scope">
                            <Button size="small" type="text" v-if="addRecoGoods.selfStatus==0" @click="goodsShelf(scope.row)">上架</Button>
                            <Button size="small" type="text" v-if="addRecoGoods.selfStatus==1" @click="goodsObtained(scope.row)">下架</Button>
                        </template>
                    </ws-table-column>
                </ws-table> 
                <!-- 折扣推荐商品数据列表 -->
                <ws-table v-show="chooseSaleGoods" :data="addRecoSaleGoods.recoGoodsList"  ref="table"   @selection-change="chooseSaleGoodsSectonChange"   style="width: 100%" >
                    <ws-table-column align="center" type="selection" width="80" fixed="left"  ></ws-table-column>
                    <ws-table-column label="分类" min-width="180" align="center">
                        <template slot-scope="scope">
                            <span>{{scope.row.disProductCateName}}</span>
                        </template>
                    </ws-table-column>
                    <ws-table-column label="名称" min-width="220" align="center">
                        <template slot-scope="scope">
                          <Row v-for="(item,index) in (scope.row.productVOS)" :key="index" style="width:100%;height:90px;display:flex;align-items:center;text-align:left;margin-bottom:25px;">
                                <img :src="item.imgUrl" alt="" style="width:160px;height:90px;">
                                <span style="margin-left:15px;width:200px;height:90px;">{{item.productName}}</span>
                                <Button size="small" type="text" @click="delDiscountGoods(item)" style="height:30px;">删除</Button>
                            </Row>  
                            <!-- <div style="display:flex;height:80px">
                                <img :src="scope.row.imgUrl" alt="" style="width:60px;height:60px;">
                                <span style="line-height:60px;">{{scope.row.productName}}</span>
                            </div>                             -->
                        </template>
                    </ws-table-column>
                    <ws-table-column label="状态" min-width="180" align="center">
                        <template slot-scope="scope">
                            <!-- <Row v-for="(item,index) in (scope.row.productVOS)" :key="index" style="width:250px;height:100px;"> -->
                              <span>{{scope.row.status ==1 ? '已上架':'未上架'}}</span>
                            <!-- </Row> -->
                        </template>
                    </ws-table-column>
                    <ws-table-column  label="语言" min-width="180" align="center">
                        <template slot-scope="scope">
                          <Select class="ws-form-select" v-model="scope.row.languageCode" >
					            <Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index" disabled>{{item.motherTongue}}/{{item.english}}</Option>
				          </Select>
                            <!-- <span>{{scope.row.languageCode}}</span> -->
                        </template>
                    </ws-table-column>
                    <!-- <ws-table-column  label="初始价格" min-width="180" align="center">
                        
                        <template slot-scope="scope">
                            
                            <input type="text" placeholder="请输入初始的价格" v-model="scope.row.primaryPrice">
                            <Button size="small" type="text" @click="confirm(scope.row)">设置</Button>
                        
                        </template>
                    </ws-table-column> -->
					          <ws-table-column label="操作" min-width="180" align="center">
                        <template slot-scope="scope">
                            <!-- <Row v-for="(item,index) in (scope.row.productVOS)" :key="index" style="width:250px;height:100px;"> -->
                              <Button size="small" type="text" v-if="scope.row.status == 0" @click="saleGoodsShelf(scope.row)">上架</Button>
                            <Button size="small" type="text" v-if="scope.row.status == 1" @click="saleGoodsObtained(scope.row)">下架</Button>
                            <!-- </Row> -->
                        </template>
                    </ws-table-column>
                </ws-table> 
            </div>
            
        </wsSmPanel> 
        <!-- 添加推荐主题弹框 -->  
        <wsModal v-model="isShow" ok-text="保存" title="添加推荐主题" @on-ok="addTopicRecoSave" @on-cancel="addTopicRecoCancel" >
            <Form ref="from">
                <FormItem label="语言"  required>
                    <Select  clearable   style="width: 70%;" class="ws-form-select" v-model="addRecoTopic.addRecoTopicData.languageCode" @on-change="getTopicCategory">
					    <Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
                    </Select>
                </FormItem>  
                <FormItem label="主题分类"  required>
                    <Select  clearable  style="width: 70%;" v-model="addRecoTopic.addRecoTopicData.categoryId" @on-change="getTopicRecoList">
                        <Option :value="item.id" v-for="(item,index) in (addRecoTopic.addRecoTopicData.categoryList)" :key="index">{{item.name}}</Option>
                    </Select>
                </FormItem>
                <FormItem label="选择主题（有且只能选择3个）" required> 
                    <ws-table :data="addRecoTopic.addRecoTopicData.topicList" ref="table" style="width:100%;" :height="500"   @selection-change="chooseTopicChange" @select-all="selectAllDisabled">
                        <ws-table-column align="center" type="selection" width="80" fixed="left"></ws-table-column>
                        <ws-table-column align="center" label="图片" width="200" fixed="left">
                            <template slot-scope="scope">
							    <img :src="scope.row.coverImgUrl" style="width: 100px;height: 80px;" />
						    </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="活动名称" width="200" fixed="left">
                            <template slot-scope="scope">
                                <span>{{scope.row.name}}</span>
						    </template>
                        </ws-table-column>
                    </ws-table>
                </FormItem>    
            </Form>
		</wsModal>
        <!-- 新增店铺推荐 -->
        <wsModal v-model="shopRecoShow" @on-ok="addShopRecoSave" @on-cancel="addShopRecoCancel"  title="添加店铺推荐" ok-text="保存">
            <Form>
                <FormItem label="选择语言" required>
                    <Select clearable  class="ws-form-select" v-model="chooseShopDataList.addShopRecoData.languageCode">
					    <Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
                    </Select>
                </FormItem>
                <FormItem label="选择店铺" required>
                    <Select filterable clearable  style="width: 70%;" v-model="chooseShopDataList.addShopRecoData.tenantId">
                        <Option v-for="(item,index) in (chooseShopDataList.shopDataList)" :key="index" :value="item.tenantId">{{item.company}}</Option>
                    </Select>
                </FormItem> 
                <FormItem label="一句话简介" required>
                    <Input type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入..." v-model="chooseShopDataList.addShopRecoData.wDesc"/>
                </FormItem>
                <FormItem label="店铺封面(1:1)" required>
                    <!-- 上传图片 -->
                    <!-- <ws-upload-cos ref="upload" catelog="merchants" :cfile-key="chooseShopDataList.upload.fileKey" :show-upload-list="false" :format="['jpg','jpeg','png']" :max-size="2048" :on-success="uploadSuccess" type="drag" >
                        <div class="ws-middle" :style="{backgroundImage:'url('+chooseShopDataList.upload.imgData+')',backgroundRepeat:'no-repeat', backgroundPosition:'center center', backgroundSize: '100% auto',width:'100%',height:'250px'}" style="border: 1px solid #ccc;cursor: pointer;">

                        </div>    
                    </ws-upload-cos> -->
                    <!-- 备注 -->
                    <!-- <div>只支持JPG .PNG格式(16:9)</div> -->
                    <ws-upload-cos ref="coverUpload" catelog="topic" :show-upload-list="false" :format="['jpg','jpeg','png']" :max-size="2048" :on-success="uploadCoverSuccess" :auto-upload="false" :on-file-list="uploadCoverFileList">
                            <div class="ws-middle" :style="positionStyle" style="border: 1px solid #ccc;cursor: pointer;">
                                <span v-if="cropper.datas.cover.base64 == ''">封面图片</span>
                                <img :src="cropper.datas.cover.base64" :style="positionStyle" v-if="cropper.datas.cover.base64 != ''"/>
                            </div>
                        </ws-upload-cos>
                    <span style="color:red">图片尺寸比例为{{cropper.config.fixedNumber}}</span>

                </FormItem>
                <!-- <FormItem label="店铺描述" required>
                    <textarea name="" id="" cols="50" rows="5" v-model=""></textarea>
                </FormItem> -->
            </Form>    
        </wsModal>
        <ws-cropper v-model="cropper.show" :img="cropper.imgData" :config="cropper.config" @crop-ok="cropOk"></ws-cropper>
        <!-- 新增商品推荐 -->
        <wsModal  v-model="goodsRecoShow"  title="添加商品推荐" ok-text="保存" :width="1400"  @on-ok="addGoodsRecoSave" @on-cancel="addGoodsRecoCancel" >
            <wsSmPanel @simple-query="queryResult" :page="addRecoGoods.page"   @page-change="serachDataList">
                <!-- 筛选查询 -->
                <div slot="query_form">
                    <Form :model="queryForm" :label-width="100" inline>
                        <FormItem label="商品名称">
                            <Input v-model="queryPanel.model.name" placeholder="请输入"/>
                        </FormItem>
                        <FormItem label="商户名称">
                            <Input v-model="queryPanel.model.shop" placeholder="请输入"/>
                        </FormItem>
                        <FormItem label="品牌">
                            <Select v-model="queryPanel.model.brandId" filterable clearable placeholder="请输入搜索查询" >
                                <Option v-for="item in queryPanel.fields.brands" :value="item.id" :key="item.id">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="发布类型">
                            <Select clearable v-model="queryPanel.model.promotionStatus" placeholder="请选择" class="ws-form-select">
                                <Option value="0">上新</Option>
                                <Option value="1">折扣</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="销售类型">
                            <Select clearable v-model="queryPanel.model.saleType" placeholder="请选择" class="ws-form-select">
                                <Option value="1">现货</Option>
                                <Option value="2">预售</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="商品编号">
                            <Input v-model="queryPanel.model.goodsSn" placeholder="请输入"/>
                        </FormItem>
                    </Form>
                </div>
                <!-- 数据列表 -->
                <div slot="list_operate">
                    <Select class="ws-form-select" v-model="queryForm.languageCode" @on-change="chooseRecoGoodsLanguageCode">
                        <Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
                    </Select>
                </div>
                <div slot="list_data">
                    <ws-table :data="addRecoGoods.recoGoodsDataList.searchGoodsList" style="width: 100%" @selection-change="goodsSelectionChange" >
                        <ws-table-column align="center" type="selection" width="80" fixed="left"></ws-table-column>
                        <ws-table-column align="center" label="主图" width="120" fixed="left">
                            <template slot-scope="scope">
                                <img :src="scope.row.primaryPicUrl" style="width: 100px;height: 80px;" />
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="商品名称" min-width="240">
                            <template slot-scope="scope">
                                <span>{{scope.row.productName}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="店铺" min-width="160">
                            <template slot-scope="scope">
                                <span>{{scope.row.company}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="品牌" min-width="80">
                            <template slot-scope="scope">
                                <span>{{scope.row.brandName}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="发布类型">
                            <template slot-scope="scope">
                                <Tag v-if="scope.row.promotionStatus == 0" color="blue">上新</Tag>
                                <Tag v-if="scope.row.promotionStatus == 1" color="green">折扣</Tag>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="销售类型">
                            <template slot-scope="scope">
                                <Tag v-if="scope.row.saleType == 1" color="blue">现货</Tag>
                                <Tag v-if="scope.row.saleType == 2" color="green">预售</Tag>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="商品语言" width="160">
                            <template slot-scope="scope">
                                <span>{{scope.row.language}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="发布日期" width="140">
                            <template slot-scope="scope">
                                <span>{{scope.row.createDate}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="价格" fixed="right">
                            <template slot-scope="scope">
                                <!-- <span style="color: red;" v-text="scope.row.price"></span> -->
                                <span style="color: red;">{{scope.row.symbol}}{{scope.row.price}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="人民币价格" fixed="right">
                            <template slot-scope="scope">
                                <!-- <span style="color: red;" v-text="scope.row.rmbPrice"></span> -->
                                <span style="color: red;">￥{{scope.row.rmbPrice}}</span>
                            </template>
                        </ws-table-column>
                    </ws-table>
                </div>
            </wsSmPanel>
        </wsModal> 
        <!-- 新增折扣商品推荐  -->
        <wsModal v-model="showRecoSaleGoods" title="添加折扣商品推荐(默认添加折扣商品)" ok-text="保存" :width="1400" @on-ok="addSaleGoodsRecoSave" @on-cancel="addSaleGoodsRecoCancel">
            <wsSmPanel @simple-query="querySaleGoodsResult" :page="addRecoSaleGoods.page"   @page-change="serachSaleDataList">
                <!-- 筛选查询 -->
                <div slot="query_form">
                    <Form :model="queryForm" :label-width="100" inline>
                        <FormItem label="商品名称">
                            <Input v-model="queryPanel.saleGoodsData.name" placeholder="请输入"/>
                        </FormItem>
                        <FormItem label="商户名称">
                            <Input v-model="queryPanel.saleGoodsData.shop" placeholder="请输入"/>
                        </FormItem>
                        <FormItem label="品牌">
                            <Select v-model="queryPanel.saleGoodsData.brandId" filterable clearable placeholder="请输入搜索查询" >
                                <Option v-for="item in queryPanel.fields.brands" :value="item.id" :key="item.id">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="销售类型">
                            <Select clearable v-model="queryPanel.saleGoodsData.saleType" placeholder="请选择" class="ws-form-select">
                                <Option value="1">现货</Option>
                                <Option value="2">预售</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="商品编号">
                            <Input v-model="queryPanel.saleGoodsData.goodsSn" placeholder="请输入"/>
                        </FormItem>
                    </Form>
                </div>
                <!-- 数据列表 -->
                <div slot="list_operate">
                    <Select class="ws-form-select" v-model="queryForm.languageCode" @on-change="chooseSaleGoodsLanguageCode">
                        <Option :value="item.code" v-for="(item,index) in fields.languages" v-bind:key="index">{{item.motherTongue}}/{{item.english}}</Option>
                    </Select>
                    <label for="">折扣商品分类</label>
                    <Select class="ws-form-select" v-model="discountGoodsCategoryId" @on-change="chooseDiscountSaleGoodsCategory">
                      <Option :value="item.id" v-for="(item,index) in discountGoodsCategoryList" v-bind:key="index" >{{item.name}}</Option>
                    </Select>
                </div>
                <div slot="list_data">
                    <ws-table :data="addRecoSaleGoods.addRecoSaleData.searchGoodsList" style="width: 100%" @selection-change="saleGoodsSelectionChange" >
                        <ws-table-column align="center" type="selection" width="80" fixed="left"></ws-table-column>
                        <ws-table-column align="center" label="主图" width="120" fixed="left">
                            <template slot-scope="scope">
                                <img :src="scope.row.primaryPicUrl" style="width: 100px;height: 80px;" />
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="商品名称" min-width="240">
                            <template slot-scope="scope">
                                <span>{{scope.row.productName}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="店铺" min-width="160">
                            <template slot-scope="scope">
                                <span>{{scope.row.company}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="品牌" min-width="80">
                            <template slot-scope="scope">
                                <span>{{scope.row.brandName}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="发布类型">
                            <template slot-scope="scope">
                                <Tag v-if="scope.row.promotionStatus == 0" color="blue">上新</Tag>
                                <Tag v-if="scope.row.promotionStatus == 1" color="green">折扣</Tag>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="销售类型">
                            <template slot-scope="scope">
                                <Tag v-if="scope.row.saleType == 1" color="blue">现货</Tag>
                                <Tag v-if="scope.row.saleType == 2" color="green">预售</Tag>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="商品语言" width="160">
                            <template slot-scope="scope">
                                <span>{{scope.row.language}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="发布日期" width="140">
                            <template slot-scope="scope">
                                <span>{{scope.row.createDate}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="价格" fixed="right">
                            <template slot-scope="scope">
                                <!-- <span style="color: red;" v-text="scope.row.price"></span> -->
                                <span style="color: red;">{{scope.row.symbol}}{{scope.row.price}}</span>
                            </template>
                        </ws-table-column>
                        <ws-table-column align="center" label="人民币价格" fixed="right">
                            <template slot-scope="scope">
                                <!-- <span style="color: red;" v-text="scope.row.rmbPrice"></span> -->
                                <span style="color: red;">￥{{scope.row.rmbPrice}}</span>
                            </template>
                        </ws-table-column>
                    </ws-table>
                </div>           
            </wsSmPanel>   
        </wsModal>     
    </wsPage>
</template>

<script>
import Util from "../../../common/util.js";
import FileUtil from "../../../common/file.js";
import Common from "../../../common/common.js";
import $ from "jquery";

export default {
  data() {
    return {
      primaryPrice: "", //設置折扣價格
      showHlight: false,
      isShow: false, //是否显示主题推荐弹框
      shopRecoShow: false, //是否显示店铺推荐
      goodsRecoShow: false, //是否显示添加商品推荐弹框
      showRecoSaleGoods: false, //是否显示添加折扣商品推荐弹框
      discountGoodsCategoryList:[],//折扣商品分类列表
      discountGoodsCategoryId:0,//折扣商品分类id
      // tab页切换
      navTab: {
        navTabList: [
          {
            name: "banner",
            type: "1"
          },
          {
            name: "活动",
            type: "2"
          },
          {
            name: "主题",
            type: "3"
          },
          {
            name: "店铺",
            type: "4"
          },
          {
            name: "商品",
            type: "5"
          },
          {
            name: "折扣",
            type: "6"
          }
        ]
      },
      // 条件查询
      queryForm: {
        selfStatus: "2", //上架号码
        type: "", //类型
        languageCode: "zh",
        status: "2" //1=新增 2=已上架  3=已下架
      },
      queryPanel: {
        conditions: {
          activeIndex: 0,
          s0: 0,
          s1: 0
        },
        fields: {
          brands: []
        },
        model: {
          name: "",
          // status: '2',
          promotionStatus: "",
          saleType: "",
          shop: "",
          brandId: "",
          goodsSn: ""
        },
        //折扣商品查询条件
        saleGoodsData: {
          name: "",
          promotionStatus: "",
          saleType: "",
          shop: "",
          brandId: "",
          goodsSn: "",
          languageCode:'zh'
        }
      },
      table: {
        data: [],
        page: {
          total: 0, //总条数
          pageNum: 1, //当前页
          pageSize: 10 //每页显示条数
        },
        selection: [] //选中
      },
      // 语言类型
      fields: {
        languages: []
      },
      // 是否上架状态 status
      onSelf: {
        selfStatus: [
          {
            name: "新增",
            status: "1"
          },
          {
            name: "已上架",
            status: "2"
          },
          {
            name: "已下架",
            status: "3"
          }
        ]
      },
      // 店铺tab--全部/上架/下架/新增
      shopOnSelf: {
        selfStatus: [
          {
            name: "新增",
            status: "1"
          },
          {
            name: "已上架",
            status: "2"
          },
          {
            name: "已下架",
            status: "3"
          }
        ]
      },
      // 商品tab---上架/下架
      goodsOnSelf: {
        selfStatus: [
          {
            name: "已上架",
            status: "1"
          },
          {
            name: "已下架",
            status: "0"
          }
        ]
      },
      // 添加店铺推荐--选择店铺
      chooseShopDataList: {
        shopDataList: [], //存放所有的店铺名list
        chooseShopName: "", //所选择的店铺名
        addShopRecoData: {
          tenantId: "",
          languageCode: "",
          wDesc:'',
          bgImgUrl: ""
        },
        upload: {
          fileKey: "",
          imgData: ""
        },
        shopRecoList: [], //保存店铺推荐列表
        selfStatus: "2", //上架号码
        type: "", //类型
        languageCode: "zh",
        status: "2" //1=新增 2=已上架  3=已下架
      },
      // 添加推荐主题
      addRecoTopic: {
        addRecoTopicData: {
          languageCode: "",
          categoryId: "",
          categoryList: [],
          topicList: [],
          chooseTopicIds: []
        },
        selection: [], //保存所选择的主题列表
        recoTopicList: [], //推荐主题列表data--list
        selfStatus: "2", //上架号码
        type: "", //类型
        languageCode: "zh",
        status: "2" //1=新增 2=已上架  3=已下架
      },
      // 添加推荐商品
      addRecoGoods: {
        recoGoodsDataList: {
          searchGoodsList: [], //存放查询后的商品信息列表
          chooseRecoGoodsId: [], //存放所选择的商品id--list
          status: 1 //商品tab页---是否上下架
        },
        selection: [], //保存所选择的推荐商品
        selectionList: [], //保存推荐商品列表中所选择的商品
        recoGoodsList: [], //推荐商品列表data--list
        selfStatus: "1", //上架号码
        type: "", //类型
        languageCode: "zh",
        status: "1", //1=已上架  0=已下架
        page: {
          total: 0, //总条数
          pageNum: 1, //当前页
          pageSize: 10 //每页显示条数
        }
      },
      // 添加折扣商品
      addRecoSaleGoods: {
        addRecoSaleData: {
          searchGoodsList: [], //存放查询后的商品信息列表
          chooseRecoGoodsId: [] //存放所选择的折扣商品id--list
        },
        selection: [],
        selectionList: [],
        recoGoodsList: [],
        selfStatus: "1", //上架号码
        type: "", //类型
        languageCode: "zh",
        status: "1", //1=已上架  0=已下架
        page: {
          total: 0, //总条数
          pageNum: 1, //当前页
          pageSize: 10 //每页显示条数
        }
      },
      // 上传图片
      form: {
        upload: {
          fileKey: "",
          imgData: "",
          imgUrl: ""
        }
      },
      cropper: {
        show: false,
        datas: {
          top: {
            base64: ""
          },
          cover: {
            base64: ""
          }
        },
        config: {
          fixedNumber: [1, 1],
          // 只有自动截图开启 宽度高度才生效
          autoCropWidth: 288,
          autoCropHeight: 288
        }
      }
    };
  },
  computed: {
    // 当前选择banner模块
    chooseBanner() {
      return this.queryForm.type == "1";
    },
    // 当前选择活动模块
    chooseActivities() {
      return this.queryForm.type == "2";
    },
    // 当前选择主题模块
    chooseTopics() {
      return this.queryForm.type == "3";
    },
    // 当前选择店铺模块
    chooseShops() {
      return this.queryForm.type == "4";
    },
    // 当前选择商品模块
    chooseGoods() {
      return this.queryForm.type == "5";
    },
    // 当前选择折扣商品模块
    chooseSaleGoods() {
      return this.queryForm.type == "6";
    },
    /**
     * 计算样式
     */
    positionStyle() {
      return (
        "width:" +
        this.cropper.config.autoCropWidth +
        "px;height:" +
        this.cropper.config.autoCropHeight +
        "px;"
      );
    }
  },
  mounted() {
    this.init();
    let code = this.queryForm.languageCode;
    this.getDiscountGoodsCategorys(code);
  },
  methods: {
    //删除折扣商品类中的商品
    delDiscountGoods(row){
      console.log(row);
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认删除选中的商品吗?",
        onOk: function() {
          _this.axios
        .delete("/ws/ops/discount/product/" + row.id)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info(resMeta.message);
            _this.getRecoSaleGoodsList();
            _this.getDiscountGoodsCategorys(_this.queryForm.languageCode);
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
          // _this.makeSureDeleteBanner(_row.id);
        }
      });
    },
    //弹出添加折扣商品模块页面
    pop(){
      this.showRecoSaleGoods=true
      this.querySaleGoodsResult();
    },
    //获取折扣商品列表分类
    getDiscountGoodsCategorys(code){
      console.log(code);
      let that = this;
      this.discountGoodsCategoryList = [];
      this.discountGoodsCategoryId=0;
      let list = [];
      this.axios.get("/ws/ops/product/categorys?languageCode=" + code).then(function(res){
        console.log(res)
        if(res.status == 200){
          list = res.data.data ? res.data.data : [];
          // if(list.length > 0){
          //   list.forEach(function(v,index){
          //     console.log(v.languageCode)
          //     if(v.languageCode == code){
          //       list.push(v);
          //     }else{
          //       list = [];
          //     }
          //   });
          // }
          that.discountGoodsCategoryList = list;
          console.log(that.discountGoodsCategoryList)
        }
      })
    },
    // //确认修改初始价格
    confirm(row) {
      console.log(row);
      if (row.primaryPrice == "") {
        that.$Message.info("请填写价格");
        return;
      }
      var that = this;

      var params = {
        primaryPrice: row.primaryPrice
      };
      this.axios
        .put("/ws/ops/recommend/product/" + row.id, params)
        .then(function(res) {
          if (res.status == 200) {
            that.buildBannerList();
            that.$Message.info(resMeta.message);
            // console.log()
          }
        });
    },
    // //修改商品初始价格
    // editGoods(row){
    //     // let _row = row;
    //     if(!row) return;
    //     if(this.primaryPrice == 'null'){
    //         this.primaryPrice = row.primaryPrice;
    //         console.log(row)
    //     }
    // },
    //刷新
    refresh() {
      this.queryPanel.model.name = "";
      this.queryPanel.model.promotionStatus = "";
      this.queryPanel.model.saleType = "";
      this.queryPanel.model.shop = "";
      this.queryPanel.model.brandId = "";
      this.table.data = [];
      this.table.page.total = 0; //总条数
      this.table.page.pageNum = 1; //当前页
      this.table.page.pageSize = 10; //每页显示条数
      this.table.selection = []; //选中
      this.init();
    },
    init() {
      this.initLanguages();
      this.initBrands();
      this.buildBannerList();
      this.queryForm.type = "1"; //默认显示banner页
    },
    /**
     * 加载翻译语言列表
     */
    initLanguages() {
      const _this = this;
      this.axios.get("/ws/ops/v2/languages/translatable").then(response => {
        var res = response.data;
        var resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.fields.languages = res.data;
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    /**
     * 初始化品牌列表
     */
    initBrands() {
      const _this = this;
      this.axios.get("/ws/ops/brands").then(response => {
        var res = response.data;
        var resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.queryPanel.fields.brands = res.data;
        } else {
          _this.$Message.warning("初始品牌失败:" + resMeta.message);
        }
      });
    },
    // 添加推荐
    gotoAddReco() {
      this.$router.push("/recoManager/addReco");
    },
    // 查询banner列表---/ws/ops/recommend/banner/{pageSize}/{pageNum}?status=1&languageCode=zh
    // status:1.新增  2.已上架  3.已下架
    buildBannerList() {
      let _this = this;
      this.axios
        .get(
          "/ws/ops/recommend/banner/" +
            _this.table.page.pageSize +
            "/" +
            _this.table.page.pageNum +
            "?status=" +
            _this.queryForm.selfStatus +
            "&languageCode=" +
            this.queryForm.languageCode
        )
        .then(response => {
          let res = response.data;
          // console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.table.data = res.data.list;
            _this.table.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 删除banner推荐--提示框
    deleteBanner(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认删除选中的banner吗?",
        onOk: function() {
          _this.makeSureDeleteBanner(_row.id);
        }
      });
    },
    // 确认删除banner推荐
    makeSureDeleteBanner(bannerId) {
      let _this = this;
      this.axios
        .delete("/ws/ops/recommend/banner/" + bannerId)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("删除banner成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 删除推荐topic  提示框
    topicDeleteBanner(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认删除选中的推荐主题吗?",
        onOk: function() {
          _this.makeSureTopicDeleteBanner(_row.id);
        }
      });
    },
    makeSureTopicDeleteBanner(topicId) {
      let _this = this;
      this.axios.delete("/ws/ops/recommend/topic/" + topicId).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("删除主题成功");
          // 重新调用bannerlist接口
          _this.getRecoTopicList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    //  删除推荐店铺shop  提示框
    shopDeleteBanner(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认删除选中的推荐店铺吗?",
        onOk: function() {
          _this.makeSureShopDeleteBanner(_row.id);
        }
      });
    },
    makeSureShopDeleteBanner(shopId) {
      let _this = this;
      this.axiosaxios
        .delete("/ws/ops/recommend/merchant/" + shopId)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("删除推荐店铺成功");
            // 重新调用bannerlist接口
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 删除推荐商品good 提示框

    // banner置顶操作  flag
    goTop(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "top"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("banner置顶成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    //store 上移操作
    moveStoreUp(_row){
let _this = this;
      let postData = {
        id: _row.id,
        flag: "up"
      };
      _this.queryForm.type = 4;
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("店铺上移成功");
            // 重新调用bannerlist接口
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    //store 下移操作
    moveStoreDown(_row){
        let _this = this;
      let postData = {
        id: _row.id,
        flag: "down"
      };
      _this.queryForm.type = 4;
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("店铺下移成功");
            // 重新调用bannerlist接口
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    //store 置顶操作
    goStoreTop(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "top"
      };
      _this.queryForm.type = 4;
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("店铺置顶成功");
            // 重新调用bannerlist接口重新调用bannerlist接口
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // topic 置顶操作
    topicGoTop(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "top"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("topic置顶成功");
            // 重新调用bannerlist接口
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // banner上架操作
    shelf(_row) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/banner/open/" + _row.id)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("banner上架成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // topic 上架
    topicShelf(_row) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/topic/open/" + _row.id)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("主题上架成功");
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // shop 上架
    shopShelf(_row) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/merchant/open/" + _row.id)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("店铺上架成功");
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 推荐商品 上架
    goodsShelf(_row) {
      let _this = this;
      let ids = [];
      ids.push(_row.id);
      this.axios.post("/ws/ops/recommend/product/open", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品上架成功");
          _this.getRecoGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    // 折扣推荐商品 上架
    saleGoodsShelf(_row) {
      let _this = this;
      let ids = [];
      ids.push(_row.disProductCateId);
      // /discount/product/open/{id}
      // /ws/ops/recommend/product/open
      this.axios.put("/ws/ops/discount/product/open/"+ ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("折扣推荐商品上架成功");
          _this.getRecoSaleGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    // 推荐商品 批量上架
    selectSomeOnSelf() {
      let _this = this;
      let currentChooseGoodsList = _this.addRecoGoods.selectionList;
      if (currentChooseGoodsList.length == 0) {
        _this.$Message.info("请选择商品");
        return;
      }
      let ids = [];
      for (var i = 0; i < currentChooseGoodsList.length; i++) {
        ids.push(currentChooseGoodsList[i].id);
      }
      this.axios.post("/ws/ops/recommend/product/open", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品批量上架成功");
          _this.getRecoGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    // 折扣推荐商品 批量上架
    saleSelectSomeOnSelf() {
      let _this = this;
      let currentChooseGoodsList = _this.addRecoSaleGoods.selectionList;
      if (currentChooseGoodsList.length == 0) {
        _this.$Message.info("请选择商品");
        return;
      }

      let ids = [];
      for (var i = 0; i < currentChooseGoodsList.length; i++) {
        ids.push(currentChooseGoodsList[i].id);
      }
      this.axios.post("/ws/ops/recommend/product/open", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品批量上架成功");
          _this.getRecoSaleGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },

    // banner下架操作
    Obtained(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认下架该banner吗?",
        onOk: function() {
          _this.makeSureObtained(_row.id);
        }
      });
    },
    makeSureObtained(bannerId) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/banner/close/" + bannerId)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("banner下架成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },

    // topic 下架操作 提示框
    topicObtained(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认下架该主题吗?",
        onOk: function() {
          _this.makeSureTopicObtained(_row.id);
        }
      });
    },
    makeSureTopicObtained(topicId) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/topic/close/" + topicId)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("主题下架成功");
            // 重新调用bannerlist接口
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // shop 下架 提示框
    shopObtained(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认下架该店铺吗?",
        onOk: function() {
          _this.makeSureShopObtained(_row.id);
        }
      });
    },
    makeSureShopObtained(shopId) {
      let _this = this;
      this.axios
        .put("/ws/ops/recommend/merchant/close/" + shopId)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("店铺下架成功");
            // 重新调用bannerlist接口
            _this.getShopRecoList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 推荐goods 下架 提示框
    goodsObtained(_row) {
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认下架该推荐商品吗?",
        onOk: function() {
          _this.makeSureGoodsObtained(_row.id);
        }
      });
    },
    makeSureGoodsObtained(goodsId) {
      let _this = this;
      let ids = [];
      ids.push(goodsId);
      this.axios.post("/ws/ops/recommend/product/close", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品下架成功");
          // 重新调用bannerlist接口
          _this.getRecoGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },

    // 折扣推荐goods 下架 提示框
    saleGoodsObtained(_row) {
      console.log(_row);
      let _this = this;
      this.$confirm({
        title: "操作提示",
        width: 300,
        content: "你确认下架该折扣推荐商品吗?",
        onOk: function() {
          _this.makeSureSaleGoodsObtained(_row.disProductCateId);
        }
      });
    },

    makeSureSaleGoodsObtained(goodsId) {
      let _this = this;
      let ids = [];
      ids.push(goodsId);
      console.log(goodsId);
      //  /ws/ops/recommend/product/close
      this.axios.put("/ws/ops/discount/product/close/" + ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("折扣推荐商品下架成功");
          // 重新调用bannerlist接口
          _this.getRecoSaleGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },

    // 批量下架 推荐商品  弹框提示
    selectSomeObtain() {
      let _this = this;
      let currentChooseGoodsListLength =
        _this.addRecoGoods.selectionList.length;
      if (currentChooseGoodsListLength == 0) {
        this.$Message.info("请选择商品");
        return;
      }
      this.$confirm({
        title: "操作提示",
        width: 300,
        content:
          "你确认下架这" + currentChooseGoodsListLength + "件推荐商品吗?",
        onOk: function() {
          _this.makeSureSelectSomeObtain();
        }
      });
    },
    makeSureSelectSomeObtain() {
      // 确认执行批量下架推荐商品操作
      let _this = this;
      let currentChooseGoodsList = _this.addRecoGoods.selectionList;
      let ids = [];
      for (var i = 0; i < currentChooseGoodsList.length; i++) {
        ids.push(currentChooseGoodsList[i].productId);
      }
      this.axios.post("/ws/ops/recommend/product/close", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品批量下架成功");
          // 重新调用bannerlist接口
          _this.getRecoGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },

    // 批量下架 折扣推荐商品  弹框提示
    saleSelectSomeObtain() {
      let _this = this;
      let currentChooseGoodsListLength =
        _this.addRecoSaleGoods.selectionList.length;
      if (currentChooseGoodsListLength == 0) {
        this.$Message.info("请选择商品");
        return;
      }
      this.$confirm({
        title: "操作提示",
        width: 300,
        content:
          "你确认下架这" + currentChooseGoodsListLength + "件推荐商品吗?",
        onOk: function() {
          _this.makeSureSaleSelectSomeObtain();
        }
      });
    },
    makeSureSaleSelectSomeObtain() {
      // 确认执行批量下架折扣推荐商品操作
      let _this = this;
      let currentChooseGoodsList = _this.addRecoSaleGoods.selectionList;
      let ids = [];
      for (var i = 0; i < currentChooseGoodsList.length; i++) {
        ids.push(currentChooseGoodsList[i].productId);
      }
      this.axios.post("/ws/ops/recommend/product/close", ids).then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          _this.$Message.info("推荐商品批量下架成功");
          // 重新调用bannerlist接口
          _this.getRecoSaleGoodsList();
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },
    // banner上移操作
    moveUp(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "up"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("banner上移成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // topic 上移操作
    topicMoveUp(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "up"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("topic上移成功");
            // 重新调用bannerlist接口
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // banner下移操作
    moveDown(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "down"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("banner下移成功");
            // 重新调用bannerlist接口
            _this.buildBannerList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // topic 下移操作
    topicMoveDown(_row) {
      let _this = this;
      let postData = {
        id: _row.id,
        flag: "down"
      };
      this.axios
        .post("/ws/ops/recommend/move/" + _this.queryForm.type, postData)
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("topic下移成功");
            // 重新调用bannerlist接口
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },

    // banner选择上下架--切换状态数据
    chooseSlelfStatus() {
      let _this = this;
      _this.queryForm.status = _this.queryForm.selfStatus;
      //重新调用bannerlist接口
      _this.buildBannerList();
    },
    // banner选择语言类型
    chooseLanguageCode() {
      let _this = this;
      // _this.queryForm.languageCode=_this.queryForm.languageCode;
      //重新调用bannerlist接口
      _this.buildBannerList();
    },
    // 主题选择 上下架
    topicChooseSlelfStatus() {
      let _this = this;
      _this.addRecoTopic.status = _this.addRecoTopic.selfStatus;
      _this.getRecoTopicList();
    },
    // 主题选择 语言类型
    topicChooseLanguageCode() {
      let _this = this;
      // _this.addRecoTopic.languageCode=_this.addRecoTopic.languageCode;
      _this.getRecoTopicList();
    },
    // 店铺选择 上下架
    shopChooseSlelfStatus() {
      let _this = this;
      _this.chooseShopDataList.status = _this.chooseShopDataList.selfStatus;
      _this.getShopRecoList();
    },
    // 店铺选择 语言类型
    shopChooseLanguageCode() {
      let _this = this;
      // _this.chooseShopDataList.languageCode=_this.chooseShopDataList.languageCode;
      _this.getShopRecoList();
    },
    //  商品选择 上下架
    goodsChooseSlelfStatus() {
      let _this = this;
      _this.addRecoGoods.status = _this.addRecoGoods.selfStatus;
      // console.log( _this.addRecoGoods.status);
      _this.getRecoGoodsList(); //获取推荐商品列表
    },
    //  折扣商品选择 上下架
    saleGoodsChooseSlelfStatus() {
      this.getRecoSaleGoodsList();
    },
    //  商品选择 语言类型
    goodsChooseLanguageCode() {
      let _this = this;
      // _this.addRecoGoods.languageCode=_this.addRecoGoods.languageCode;
      _this.getRecoGoodsList(); //获取推荐商品列表
    },
    //  折扣商品选择 语言类型
    saleGoodsChooseLanguageCode() {
      this.getRecoSaleGoodsList();
    },

    // 选择banner/活动/主题/店铺/商品
    hasChangeType() {
      let _this = this;
      let currentType = _this.queryForm.type;
      console.log(_this.queryForm.type);
      
      switch (currentType) {
        case "2":
          _this.table.page.total = 0;
          _this.table.page.pageNum = 1;
          _this.table.page.pageSize = 10;
          break;
        case "3":
          _this.getRecoTopicList();
          break;
        case "4":
          _this.getShopName(); //获取推荐店铺
          _this.getShopRecoList(); //获取推荐店铺列表
          break;
        case "5":
          _this.getRecoGoodsList(); //获取推荐商品列表
          break;
        case "6":
        // _this.addRecoSaleGoods.selfStatus = 0;
        // this.queryForm.selfStatus = 3;
        // if(!_this.table.page.pageSize){
        //   this.table.page.pageSize = 10;
        // }
        // console.log(this.table.page.pageSize)
          _this.getRecoSaleGoodsList(); //获取折扣推荐商品列表
          break;
        default:
          // _this.queryForm.selfStatus='2';
          _this.buildBannerList();
      }
    },
    // 选择主题
    handleSelectionChange(val) {
      this.table.selection = val;
    },
    // 添加推荐主题---选择主题
    chooseTopicChange(val) {
      this.addRecoTopic.selection = val;
    },
    // 添加推荐主题---清除全选
    selectAllDisabled(row) {
      this.$refs.table.clearSelection();
    },
    // 选择添加商品推荐
    goodsSelectionChange(val) {
      this.addRecoGoods.selection = val;
      console.log(this.addRecoGoods.selection);
    },
    // 选择添加折扣商品推荐
    saleGoodsSelectionChange(val) {
      this.addRecoSaleGoods.selection = val;
    },

    // 选择推荐的商品列表
    chooseGoodsSectonChange(val) {
      // this.$refs.table.clearSelection();
      this.addRecoGoods.selectionList = val;
      // this.$refs.table.toggleRowSelection(row,true);
    },
    // 选择推荐的折扣商品列表
    chooseSaleGoodsSectonChange(val) {
      this.addRecoSaleGoods.selectionList = val;
      console.log(this.addRecoSaleGoods.selectionList);
    },

    //  获取店铺名称
    getShopName() {
      let _this = this;
      this.axios.get("/ws/ops/recommend/merchant").then(response => {
        let res = response.data;
        let resMeta = res.meta;
        if (0 == resMeta.code) {
          // _this.$Message.info('查询店铺成功');
          _this.chooseShopDataList.shopDataList = res.data;
        } else {
          _this.$Message.warning(resMeta.message);
        }
      });
    },

    /**
            图片上传成功保存地址url
             */
    // uploadSuccess(response, file, fileList) {
    // 	if(0 == response.meta.code) {
    // 		this.chooseShopDataList.upload.fileKey = response.data.fileId;
    //         this.chooseShopDataList.addShopRecoData.bgImgUrl=response.data.Location;
    //         this.chooseShopDataList.upload.imgData=response.data.Location;
    // 	}
    // },

    /**
     * 封面图上传成功
     */
    uploadCoverSuccess(response, file, fileList) {
      let _this = this;
      if (0 == response.meta.code) {
        _this.chooseShopDataList.addShopRecoData.bgImgUrl =
          response.data.Location;
        _this.chooseShopDataList.upload.imgData = response.data.Location;
        let postData = {
          tenantId: _this.chooseShopDataList.addShopRecoData.tenantId,
          languageCode: _this.chooseShopDataList.addShopRecoData.languageCode,
          // "wDesc":_this.chooseShopDataList.addShopRecoData.wDesc,
          bgImgUrl: _this.chooseShopDataList.addShopRecoData.bgImgUrl
        };
        this.updateBannerBasic(postData, function() {
          _this.commitShopReco();
        });
      }
    },

    updateBannerBasic(postData, callback) {
      let _this = this;
      this.axios
        .post(
          "/ws/ops/recommend/merchant",
          _this.chooseShopDataList.addShopRecoData
        )
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("新增推荐店铺成功");
            _this.shopRecoShow = false;
            _this.getShopRecoList(); //获取店铺推荐列表
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },

    /**
     * 封面图片
     */
    uploadCoverFileList(fileList) {
      let _this = this;
      let newFile = fileList[0];
      FileUtil.readFile(newFile, function(result, currFile) {
        _this.addTopImg(result);
      });
    },

    /**
     * 截图OK
     */
    cropOk(data) {
      let action = data.action;
      let imgBase64Data = data.data;
      this.cropper.datas.cover.base64 = imgBase64Data;
      this.cropper.imgData = data;
    },

    /**
     * 添加顶部图片
     */
    addTopImg(result) {
      this.cropper.imgData = result;
      this.cropper.show = true;
    },

    /**
     * 保存封面图
     */
    saveCoverImg() {
      let data = this.cropper.datas.cover.base64;
      let fileName = "topic_" + new Date().getTime() + ".jpg";
      let newFile = FileUtil.dataURLtoFile(data, fileName);
      this.$refs.coverUpload.execUpload([newFile]);
    },

    // 添加店铺推荐---提交数据
    commitShopReco() {
      this.saveCoverImg();
    },
    // 获取每日好店列表  /ws/ops/recommend/merchant/{pageSize}/{pageNum}?status=1&languageCode=zh
    getShopRecoList() {
      let _this = this;
      // _this.table.page.pageSize = 10;
      this.axios
        .get(
          "/ws/ops/recommend/merchant/" +
            _this.table.page.pageSize +
            "/" +
            _this.table.page.pageNum +
            "?status=" +
            _this.chooseShopDataList.selfStatus +
            "&languageCode=" +
            this.chooseShopDataList.languageCode
        )
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.chooseShopDataList.shopRecoList = res.data.list;
            _this.table.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    /**
     * 新增店铺推荐保存
     */
    addShopRecoSave() {
      let coverImgData = this.cropper.datas.cover.base64; //封面图url
      let chooseLanguage = this.chooseShopDataList.addShopRecoData.languageCode; //语言code
      let chooseShop = this.chooseShopDataList.addShopRecoData.tenantId; //店铺id
      let shopWDesc=this.chooseShopDataList.addShopRecoData.wDesc; // 店铺简介
      if (Util.vad.isBlank(chooseLanguage)) {
        this.$Message.info("请选择语言");
        return;
      } else if (Util.vad.isBlank(chooseShop)) {
        this.$Message.info("请选择店铺");
        return;
      } else if (Util.vad.isBlank(shopWDesc)) {
        this.$Message.info("请输入简介");
        return;
      } else if (Util.vad.isBlank(coverImgData)) {
        this.$Message.info("封面图必须上传");
        return;
      }
      //1.保存
      this.commitShopReco();
    },
    /**
     * 新增店铺推荐取消
     */
    addShopRecoCancel() {
      this.shopRecoShow = false;
    },
    // 获取主题分类
    getTopicCategory() {
      let _this = this;
      _this.addRecoTopic.addRecoTopicData.categoryId = "";
      _this.addRecoTopic.addRecoTopicData.categoryList = [];
      _this.addRecoTopic.addRecoTopicData.topicList = [];
      _this.addRecoTopic.addRecoTopicData.chooseTopicIds = [];
      this.axios
        .get(
          "/ws/ops/topic/categorys?languageCode=" +
            _this.addRecoTopic.addRecoTopicData.languageCode
        )
        .then(response => {
          let res = response.data;
          console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoTopic.addRecoTopicData.categoryList = res.data;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 获取对应主题分类下的主题列表
    getTopicRecoList() {
      let _this = this;
      this.axios
        .put(
          "/ws/ops/v2/topic/" + _this.addRecoTopic.addRecoTopicData.categoryId
        )
        .then(response => {
          let res = response.data;
          console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoTopic.addRecoTopicData.topicList = res.data;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 验证添加推荐主题---是否有空项
    addTopicRecoSave() {
      let languageCode = this.addRecoTopic.addRecoTopicData.languageCode;
      let topicCategoryId = this.addRecoTopic.addRecoTopicData.categoryId;
      let chooseTopicIdList = this.addRecoTopic.selection;
      let chooseTopicIdListLength = chooseTopicIdList.length;
      if (Util.vad.isBlank(languageCode)) {
        this.$Message.info("请选择语言");
        return;
      } else if (Util.vad.isBlank(topicCategoryId)) {
        this.$Message.info("请选择主题分类");
        return;
      } /*else if(chooseTopicIdListLength!=1){
                    this.$Message.info('请选择主题,有且只能选择一个');              
                    return;                  
                }*/
      this.addTopicRecoConfirm();
    },
    // 保存主题推荐数据
    addTopicRecoConfirm() {
      let _this = this;
      _this.addRecoTopic.addRecoTopicData.chooseTopicIds = [];
      let chooseTopicIdList = _this.addRecoTopic.selection;
      for (var i = 0; i < chooseTopicIdList.length; i++) {
        _this.addRecoTopic.addRecoTopicData.chooseTopicIds.push(
          chooseTopicIdList[i].id
        );
      }
      let addTopicRecoData = {
        topicCategoryId: _this.addRecoTopic.addRecoTopicData.categoryId,
        languageCode: _this.addRecoTopic.addRecoTopicData.languageCode,
        topicIds: _this.addRecoTopic.addRecoTopicData.chooseTopicIds
      };
      this.axios
        .post("/ws/ops/recommend/topic", addTopicRecoData)
        .then(response => {
          let res = response.data;
          console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("新增推荐主题成功");
            _this.isShow = false;
            _this.getRecoTopicList();
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 取消主题推荐数据
    addTopicRecoCancel() {
      this.isShow = false;
    },
    // 获取推荐主题列表  /ws/ops/recommend/topics/{pageSize}/{pageNum}?status=1&languageCode=zh
    getRecoTopicList() {
      let _this = this;
      this.axios
        .get(
          "/ws/ops/recommend/topic/" +
            _this.table.page.pageSize +
            "/" +
            _this.table.page.pageNum +
            "?status=" +
            _this.addRecoTopic.selfStatus +
            "&languageCode=" +
            _this.addRecoTopic.languageCode
        )
        .then(response => {
          let res = response.data;
          // console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoTopic.recoTopicList = res.data.list;
            _this.table.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 添加商品推荐--查询结果 /ws/ops/recommend/product/list?name=&company=?brand=&promotionStatus=&saleType=
    queryResult() {
      let _this = this;
      let pageSize = _this.addRecoGoods.page.pageSize;
      let pageNum = _this.addRecoGoods.page.pageNum;
      this.axios
        .get("/ws/ops/recommend/product/list/" + pageSize + "/" + pageNum, {
          params: _this.queryPanel.model
        })
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoGoods.recoGoodsDataList.searchGoodsList =
              res.data.list;
            _this.addRecoGoods.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.addRecoGoods.page.pageNum = res.data.pageNum;
            } else {
              _this.addRecoGoods.page.pageNum = 1;
            }
            _this.addRecoGoods.page.pageNum = res.data.pageNum;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 查询折扣商品--推荐结果
    querySaleGoodsResult() {
      let _this = this;
      let pageSize = _this.addRecoSaleGoods.page.pageSize;
      let pageNum = _this.addRecoSaleGoods.page.pageNum;
      _this.queryPanel.saleGoodsData.languageCode = this.queryForm.languageCode;
      //ws/ops/recommend/product/0/10/1?status=0&languageCode=zh
      this.axios
        .get("/ws/ops/recommend/product/list/" + pageSize + "/" + pageNum, {
          params: _this.queryPanel.saleGoodsData
        })
        .then(response => {
          // _this.addRecoSaleGoods.selection=[];
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoSaleGoods.addRecoSaleData.searchGoodsList =
              res.data.list;
            _this.addRecoSaleGoods.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.addRecoSaleGoods.page.pageNum = res.data.pageNum;
            } else {
              _this.addRecoSaleGoods.page.pageNum = 1;
            }
            _this.addRecoSaleGoods.page.pageNum = res.data.pageNum;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 表单查询
    serachDataList() {
      this.queryResult();
    },

    serachSaleDataList() {
      this.querySaleGoodsResult();
    },

    // 切换语言
    chooseRecoGoodsLanguageCode() {
      this.queryResult();
    },
    //添加折扣商品推荐分类
    chooseDiscountSaleGoodsCategory(){
      if(this.discountGoodsCategoryId == undefined) this.discountGoodsCategoryId = 0;
    //  console.log(this.discountGoodsCategoryId)
    },
    // 添加折扣商品推荐--切换语言
    chooseSaleGoodsLanguageCode() {
      let code = this.queryForm.languageCode;
      this.querySaleGoodsResult();
      // this.discountGoodsCategoryList = [];
      this.getDiscountGoodsCategorys(code);
      // console.log(this.discountGoodsCategoryId);
    },
    // 分页表单查询
    serachPageListData() {
      // this.hasChangeType();
    },
    // 保存提交勾选的推荐商品
    addGoodsRecoSave() {
      let chooseRecoGoodsList = this.addRecoGoods.selection;
      let chooseRecoGoodsListLength = chooseRecoGoodsList.length;
      if (chooseRecoGoodsListLength == 0) {
        this.$Message.info("请勾选推荐的商品");
        return;
      }
      this.addGoodsRecoConfirm();
    },
    // 保存提交勾选的折扣推荐商品
    addSaleGoodsRecoSave() {
      let chooseRecoGoodsList = this.addRecoSaleGoods.selection;
      let chooseRecoGoodsListLength = chooseRecoGoodsList.length;
      if (chooseRecoGoodsListLength == 0) {
        this.$Message.info("请勾选推荐的商品");
        return;
      }
      if(this.discountGoodsCategoryId == 0){
        this.$Message.info("请选择折扣商品分类");
        return;
      }
      this.addSaleGoodsRecoConfirm();
    },
    /**
     * 验证提交的推荐商品--不能为空
     */
    addGoodsRecoConfirm() {
      let _this = this;
      let chooseRecoGoodsList = _this.addRecoGoods.selection;
      _this.addRecoGoods.recoGoodsDataList.chooseRecoGoodsId = [];
      for (var i = 0; i < chooseRecoGoodsList.length; i++) {
        _this.addRecoGoods.recoGoodsDataList.chooseRecoGoodsId.push(
          chooseRecoGoodsList[i].productId
        );
      }
      let productIds = _this.addRecoGoods.recoGoodsDataList.chooseRecoGoodsId;
      this.axios
        .post("/ws/ops/recommend/product/0", productIds)
        .then(response => {
          let res = response.data;
          console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("新增推荐商品成功");

            this.getRecoGoodsList();

            _this.goodsRecoShow = false;
            _this.table.page.total = res.data.total;

            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },

    // 验证提交的折扣推荐商品--不能为空
    addSaleGoodsRecoConfirm() {
      let _this = this;
      let chooseRecoGoodsList = _this.addRecoSaleGoods.selection;
      console.log(this.discountGoodsCategoryId)
      _this.addRecoSaleGoods.addRecoSaleData.chooseRecoGoodsId = [];
      for (var i = 0; i < chooseRecoGoodsList.length; i++) {
        _this.addRecoSaleGoods.addRecoSaleData.chooseRecoGoodsId.push(
          chooseRecoGoodsList[i].productId
        );
        console.log(this.addRecoSaleGoods.addRecoSaleData.chooseRecoGoodsId);
      }
      let productIds = _this.addRecoSaleGoods.addRecoSaleData.chooseRecoGoodsId;
      let params = {
        "productCateId" : this.discountGoodsCategoryId,
        "productIds" : productIds
      };
      console.log(productIds);
      //  /ws/ops/discount/product
      this.axios
        .post("/ws/ops/discount/product", params)
        .then(response => {
          let res = response.data;
          console.log(res);
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.$Message.info("新增折扣推荐商品成功");

            _this.getRecoSaleGoodsList();

            _this.showRecoSaleGoods = false;
            _this.table.page.total = res.data.total;

            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },

    // 打开推荐商品弹框
    showRecoGoods() {
      this.goodsRecoShow = true;
    },

    // 取消提交勾选的推荐商品
    addGoodsRecoCancel() {
      this.goodsRecoShow = false;
      this.getRecoGoodsList();
    },

    addSaleGoodsRecoCancel() {
      this.showRecoSaleGoods = false;
      this.getRecoSaleGoodsList();
    },

    // 查询推荐商品数据列表
    getRecoGoodsList() {
      let _this = this;
      let pageSize = _this.table.page.pageSize;
      let pageNum = _this.table.page.pageNum;
      let status = this.addRecoGoods.selfStatus ? this.addRecoGoods.selfStatus : '';
      // 推荐商品列表
      this.axios
        .get(
          "/ws/ops/recommend/product/0/" +
            pageSize +
            "/" +
            pageNum +
            "?status=" +
            status +
            "&languageCode=" +
            this.addRecoGoods.languageCode
        )
        .then(response => {
          let res = response.data;
          let resMeta = res.meta;
          if (0 == resMeta.code) {
            _this.addRecoGoods.recoGoodsList = res.data.list;
            _this.table.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
          }
        });
    },
    // 查询折扣推荐商品数据列表
    getRecoSaleGoodsList() {
      let _this = this;
      _this.addRecoSaleGoods.recoGoodsList = [];
      // console.log(this.table.page.pageSize)
      let pageSize = _this.table.page.pageSize ;
      let pageNum = _this.table.page.pageNum ;
      let status = _this.addRecoSaleGoods.selfStatus ? _this.addRecoSaleGoods.selfStatus : '';
      // console.log(status)
      // 推荐商品列表
      // this.axios
      //   .get(
      //     "/ws/ops/recommend/product/1/" +
      //       pageSize +
      //       "/" +
      //       pageNum +
      //       "?status=" +
      //       this.addRecoSaleGoods.selfStatus +
      //       "&languageCode=" +
      //       this.addRecoSaleGoods.languageCode
      //   )
      //   .then(response => {
      //     let res = response.data;
      //     let resMeta = res.meta;
      //     if (0 == resMeta.code) {
      //       // if(res.data.list.length > 0){
      //       //     res.data.list.forEach(function(v,index){
      //       //         v.primaryPrice = '';
      //       //     });
      //       // }
      //       _this.addRecoSaleGoods.recoGoodsList = res.data.list;
      //       _this.table.page.total = res.data.total;
      //       if (res.data.pageNum > 1) {
      //         _this.table.page.pageNum = res.data.pageNum;
      //       } else {
      //         _this.table.page.pageNum = 1;
      //       }
      //       _this.table.page.pageSize = res.data.pageSize;
      //     } else {
      //       _this.$Message.warning(resMeta.message);
      //     }
      //   });
      this.axios.get('/ws/ops/discount/products/'+ pageSize +'/'+ pageNum +'?languageCode=' + this.addRecoSaleGoods.languageCode + '&status=' + status).then(response =>{
          let res = response.data;
          let resMeta = res.meta;
          // console.log(res);
          if(0 == resMeta.code){
            // console.log(res.data.total);
             _this.addRecoSaleGoods.recoGoodsList = res.data.list;
            _this.table.page.total = res.data.total;
            if (res.data.pageNum > 1) {
              _this.table.page.pageNum = res.data.pageNum;
            } else {
              _this.table.page.pageNum = 1;
            }
            // _this.table.page.pageSize = res.data.pageSize;
          } else {
            _this.$Message.warning(resMeta.message);
            // if(_this.table.page.pageSize) _this.table.page.pageSize = 10;
          }
      });
    }
  }
};
</script>

<style scoped>
</style>

